﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pgCerUpload.aspx.cs" Inherits="EGuayas.Web.Licenciamiento.dma.pgCerUpload" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link  href="~/Resources/css/Style.css"  rel="stylesheet" />
    <!-- Load Ext JS --> 
    <script src="../../../Resources/js/Global.js"></script>
   
</head>
<body>  
    <form id="Form1" runat="server"> 
       <ext:ResourceManager ID="pgIdCategManager" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
            <Items>   
                <ext:Window 
                    ID="winFirma" 
                    runat="server" 
                    Closable="false"
                    Resizable="false"
                    Height="350" 
              
                    Draggable="false"
                    Width="450"
                    Y="15"
	              
                    ButtonAlign="Center"
                    Modal="true"
                    BodyPadding="5"
                    Layout="Form"
                    hidden="true" 
                    closeaction="Hide">
                    <Items>
                           <ext:FormPanel 
                                ID     ="forPanelClaveFir" 
                                Border ="false"
                                runat  ="server"
                                Width  ="430"
                                BodyPadding="10"
                                Layout="Form">
                                <Defaults>
                                    <ext:Parameter Name="anchor" Value="85%" Mode="Value" />
                                    <ext:Parameter Name="allowBlank" Value="false" Mode="Raw" />
                                    <ext:Parameter Name="msgTarget" Value="side" Mode="Value" />
                                 </Defaults>
                                <Items>       
                                   <ext:Label runat="server" ID="lblDetailsFirma" Text="A continuación valide los datos  del certificado a utilizar para la firma de documentos:"></ext:Label>                      
                                   <ext:Panel ID="txtDetailsFirma"  runat="server"  Flex="1" AutoScroll="true"  Header="false">
	                               </ext:Panel>   
                                  
                                </Items> 
                                    <Listeners>
                                    <ValidityChange Handler="#{btnFirmar}.setDisabled(!valid);" />
                                </Listeners>
                            </ext:FormPanel>
                    </Items>
                    <Buttons>
                        <ext:Button ID="btnFirmar"  runat="server" Text="Confirmar">
                            <DirectEvents>
                                    <Click OnEvent="btnFirma_Click"   Failure="Ext.Msg.show({ 
                                            title   : 'Error', 
                                            msg     : 'Error', 
                                            minWidth: 200, 
                                            modal   : true, 
                                            icon    : Ext.Msg.ERROR, 
                                            buttons : Ext.Msg.OK 
                                        });" >
                                            <ExtraParams>
                                               <ext:Parameter Name="clave"  Value ="#{txtClave}.getValue()"   Mode="Raw" /> 
                                              
                                            </ExtraParams>
                                           <EventMask ShowMask="True"></EventMask>			    
                                    </Click>                             
                           </DirectEvents>  
                        </ext:Button>
                        <ext:Button ID="btnCancelar"  runat="server" Text="Cancelar"  OnClientClick="AppGlobalJs.closeWin(#{winFirma})">                   
                        </ext:Button>
                    </Buttons>
                          <Listeners>
                            <BeforeHide Handler="#{forPanelClaveFir}.getForm().reset();"></BeforeHide>              
                        </Listeners>
                </ext:Window>             
                <ext:FormPanel
                    ID="forPanelDoc"
                    Region="Center"
                    Border="true"
                    runat="server"
                    Width="430"
                    ButtonAlign="Center"
                    BodyPadding="10"
                    Layout="Form">
                    <Defaults>
                        <ext:Parameter Name="anchor" Value="85%" Mode="Value" />                    
                        <ext:Parameter Name="msgTarget" Value="side" Mode="Value" />
                    </Defaults>
                    <Items>                                               
                        <ext:Label ID="lblKey" 
                                        runat="server" 
                                        Text="Ingrese clave de certificado" 
                                        Icon="TextfieldKey" 
                                
                                        />
                                   <ext:TextField 
                                    ID="txtClave" 
                                    runat="server"                            
                                    InputType="Password"                           
                                    AllowBlank="false" 
                                    BlankText="Su clave es requerida"                                              
                                     /> 
                         <ext:Container ID="Container3" runat="server"
                                    Layout="HBoxLayout"
                                    MarginSpec="0 0 0 0">
                                    <Items>
                                        <ext:FileUploadField
                                            ID="FileUploadDocUp"                      
                                            runat="server"
                                            EmptyText="Seleccione documento"
                                            FieldLabel="Documento"
                                            ButtonText=""
                                             AnchorHorizontal="70"
                                            Icon="ImageAdd" AllowBlank="false"> 
                                                                                                                                   
                                          </ext:FileUploadField>
                                          <ext:Label  runat="server" Text="&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;"></ext:Label>
                                          <ext:Button ID="btnWinDocOk" runat="server" Text="Cargar" Disabled="true" Width="90" Icon="Accept">
                                            <DirectEvents>
                                                <Click
                                                   
                                                    OnEvent="UploadClick"
                                                    Before="return  wucJsCerUp.checkExtension();"
                                                    Failure="Ext.Msg.show({ 
                                                            title   : 'Error', 
                                                            msg     : 'Error', 
                                                            minWidth: 200, 
                                                            modal   : true, 
                                                            icon    : Ext.Msg.ERROR, 
                                                            buttons : Ext.Msg.OK 
                                                        });">
                                                    <ExtraParams>
                                                       <ext:Parameter Name="clave"  Value ="#{txtClave}.getValue()"   Mode="Raw" /> 
                                                    </ExtraParams>
                                                 <EventMask ShowMask="true"></EventMask></Click>
                                            </DirectEvents>   
                                        </ext:Button>
                                        </Items>
                                        </ext:Container>
                         <ext:Panel ID="pnlDetailsFirma"  runat="server" Title="Datos de Certificado"  Flex="1" AutoScroll="true" Icon="ShapeSquareKey" Hidden="true">
	                                      </ext:Panel>
                    </Items>
                    <Listeners>
                        <ValidityChange Handler="#{btnWinDocOk}.setDisabled(!valid);" />
                    </Listeners>
                    <Buttons>
                        
                    </Buttons>
                </ext:FormPanel>
                        
                
            </Items>
       </ext:Viewport>
    </form>
    <ext:XScript ID="XScript1" runat="server">
        <script  type="text/javascript">
            var wucJsCerUp    = new Object();
            //
            wucJsCerUp.hideBtnParent=function() 
            {
                try
                {
                    if (window.parent.App!=null && window.parent.App.btnCloseFirmarDoc)
                    {
                        window.parent.App.btnCloseFirmarDoc.show();
                    }

                } catch (jsbug) {
                    AppGlobalJs.showBug("wucJsCerUp.hideBtnParent: " + jsbug)
                }
            };
            wucJsCerUp.checkExtension=function() 
            {
                try
                {
                    var done     = false;
                    var flag     = false;
                    var value    = #{FileUploadDocUp}.getValue();                  
                    value  = value.toUpperCase();               
                    flag   = (value.match('\.P12$')!=null);
                    if (flag==false) {
                        Ext.Msg.show({
                            title: 'Error',
                            msg: AppLabelGlobalJs.pg_cer_invalid,
                            buttons: Ext.Msg.ERROR,                   
                            animEl: 'elId'
                        });
                    }
                    return (flag);

                } catch (jsbug) {
                    AppGlobalJs.showBug("wucJsCerUp.checkExtension: " + jsbug)
                }
            };
       </script>
    </ext:XScript>     
</body>
</html>
